package com.x.attendance.core.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import com.x.base.core.entity.annotation.*;
import org.apache.openjpa.persistence.jdbc.Index;

import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.project.annotation.FieldDescribe;

/**
 * 考勤记录实体类
 * @author Manus AI
 */
@ContainerEntity
@Entity
@Table(name = PersistenceProperties.AttendanceRecord.table, uniqueConstraints = {
		@UniqueConstraint(name = PersistenceProperties.AttendanceRecord.table + JpaObject.IndexNameMiddle
				+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
						JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class AttendanceRecord extends SliceJpaObject {

	private static final long serialVersionUID = 1325197931747463982L;
	private static final String TABLE = PersistenceProperties.AttendanceRecord.table;

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	@FieldDescribe("数据库主键,自动生成.")
	@Id
	@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
	private String id = createId();

	@Override
	public void onPersist() {
	}

	/*
	 * =============================================================================
	 * ===== 以下为考勤记录字段
	 * =============================================================================
	 */

	public static final String employeeId_FIELDNAME = "employeeId";
	@FieldDescribe("员工ID")
	@Index(name = TABLE + IndexNameMiddle + employeeId_FIELDNAME)
	@Column(length = length_id, name = ColumnNamePrefix + employeeId_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private String employeeId;

	public static final String deviceId_FIELDNAME = "deviceId";
	@FieldDescribe("设备ID")
	@Index(name = TABLE + IndexNameMiddle + deviceId_FIELDNAME)
	@Column(length = length_id, name = ColumnNamePrefix + deviceId_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private String deviceId;

	public static final String punchTime_FIELDNAME = "punchTime";
	@FieldDescribe("打卡时间")
	@Index(name = TABLE + IndexNameMiddle + punchTime_FIELDNAME)
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = ColumnNamePrefix + punchTime_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private Date punchTime;

	public static final String punchType_FIELDNAME = "punchType";
	@FieldDescribe("打卡类型")
	@Column(length = 50, name = ColumnNamePrefix + punchType_FIELDNAME)
	private String punchType;

	public static final String verifyMode_FIELDNAME = "verifyMode";
	@FieldDescribe("验证方式")
	@Column(length = 50, name = ColumnNamePrefix + verifyMode_FIELDNAME)
	private String verifyMode;

	public static final String syncStatus_FIELDNAME = "syncStatus";
	@FieldDescribe("同步状态")
	@Index(name = TABLE + IndexNameMiddle + syncStatus_FIELDNAME)
	@Column(length = 50, name = ColumnNamePrefix + syncStatus_FIELDNAME)
	private String syncStatus;

	public static final String syncTime_FIELDNAME = "syncTime";
	@FieldDescribe("同步时间")
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = ColumnNamePrefix + syncTime_FIELDNAME)
	private Date syncTime;

	public static final String remark_FIELDNAME = "remark";
	@FieldDescribe("备注")
	@Column(length = 500, name = ColumnNamePrefix + remark_FIELDNAME)
	private String remark;

	public static final String originalRecordId_FIELDNAME = "originalRecordId";
	@FieldDescribe("原始记录ID")
	@Column(length = 100, name = ColumnNamePrefix + originalRecordId_FIELDNAME)
	private String originalRecordId;

	// Getters and Setters
	public String getEmployeeId() {
		return employeeId;
	}

	public void setEmployeeId(String employeeId) {
		this.employeeId = employeeId;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public Date getPunchTime() {
		return punchTime;
	}

	public void setPunchTime(Date punchTime) {
		this.punchTime = punchTime;
	}

	public String getPunchType() {
		return punchType;
	}

	public void setPunchType(String punchType) {
		this.punchType = punchType;
	}

	public String getVerifyMode() {
		return verifyMode;
	}

	public void setVerifyMode(String verifyMode) {
		this.verifyMode = verifyMode;
	}

	public String getSyncStatus() {
		return syncStatus;
	}

	public void setSyncStatus(String syncStatus) {
		this.syncStatus = syncStatus;
	}

	public Date getSyncTime() {
		return syncTime;
	}

	public void setSyncTime(Date syncTime) {
		this.syncTime = syncTime;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getOriginalRecordId() {
		return originalRecordId;
	}

	public void setOriginalRecordId(String originalRecordId) {
		this.originalRecordId = originalRecordId;
	}
}

